﻿using DevExpress.XtraCharts;
using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.UC.金蝶.Service;
using Kingdee.BOS.WebApi.Client;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;

namespace DXApplicationTangche.UC.金蝶
{
    public partial class Form应付管理 : DevExpress.XtraEditors.XtraForm
    {
        private List<DouyinSaleDTO> douyinSaleDTOs销量 = new List<DouyinSaleDTO>();
        private List<DouyinSaleDTO> douyinSaleDTOs面料 = new List<DouyinSaleDTO>();

        public Form应付管理()
        {
            InitializeComponent();
            this.douyinSaleDTOs销量.Add(new DouyinSaleDTO("2021-10", 100));
            this.douyinSaleDTOs销量.Add(new DouyinSaleDTO("2021-11", 90));
            this.douyinSaleDTOs销量.Add(new DouyinSaleDTO("2021-12", 110));
            //this.douyinSaleDTOs面料.Add(new DouyinSaleDTO("20F110", 50));
            //this.douyinSaleDTOs面料.Add(new DouyinSaleDTO("19FJ21", 60));
            //this.douyinSaleDTOs面料.Add(new DouyinSaleDTO("21F58", 70));

            //DevExpress.XtraCharts.Series series = new DevExpress.XtraCharts.Series();
            //DevExpress.XtraCharts.Series series = new DevExpress.XtraCharts.Series("款式销量", ViewType.Bar);
            //DevExpress.XtraCharts.Series series2 = new DevExpress.XtraCharts.Series("面料库存", ViewType.Bar);
            //DevExpress.XtraCharts.Series series = new DevExpress.XtraCharts.Series("款式销量", ViewType.Line);
            DevExpress.XtraCharts.Series series = new DevExpress.XtraCharts.Series("21F110-3", ViewType.Line);

            //DevExpress.XtraCharts.Series series2 = new DevExpress.XtraCharts.Series("面料库存", ViewType.Line);


            chartControl1.Series.Add(series);
            foreach(DouyinSaleDTO douyinSaleDTO in this.douyinSaleDTOs销量)
            {
                series.Points.AddPoint(douyinSaleDTO.styleNameCn, douyinSaleDTO.saleCount);
            }

            //chartControl1.Series.Add(series2);
            //foreach (DouyinSaleDTO douyinSaleDTO in this.douyinSaleDTOs面料)
            //{
            //    series2.Points.AddPoint(douyinSaleDTO.styleNameCn, douyinSaleDTO.saleCount);
            //}
        }

        //private void simpleButton1_Click(object sender, EventArgs e)
        //{
        //    // 使用webapi引用组件Kingdee.BOS.WebApi.Client.dll
        //    K3CloudApiClient client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
        //    var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
        //    var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
        //    //登录结果类型等于1，代表登录成功
        //    if (resultType == 1)
        //    {
        //        //自制，产成品
        //        //String result = client.Save("BD_MATERIAL", FunctionHelper.JsonSerialization(new Root("19FJ-测试款号","YJ-B20测试面料","239")));
        //        //面料
        //        //String result = client.Save("BD_MATERIAL", FunctionHelper.JsonSerialization(new Root("17FJ-", "测试面料", "面料", "1", "m", "FYXM01_SYS", "VEN00004", "CK004")));
        //        //辅料
        //        //String result = client.Save("BD_MATERIAL", FunctionHelper.JsonSerialization(new Root("JM-21", "测试辅料", "扣", "1", "Pcs", "FYXM01_SYS", "VEN00004", "CK004")));
        //        //MaterialResultRoot materialResultRoot = FunctionHelper.JsonDeserialization<MaterialResultRoot>(result);
        //        //String Submitresult = client.Submit("BD_MATERIAL", FunctionHelper.JsonSerialization(new MaterialSubmitDTO(materialResultRoot.Result.Number, materialResultRoot.Result.Id.ToString())));
        //        //String SupplierVerifyresult = client.Audit("BD_MATERIAL", FunctionHelper.JsonSerialization(new MaterialVerifyDTO(materialResultRoot.Result.Number, materialResultRoot.Result.Id.ToString())));
        //    }
        //}

        //private void simpleButton2_Click(object sender, EventArgs e)
        //{
        //    // 使用webapi引用组件Kingdee.BOS.WebApi.Client.dll
        //    K3CloudApiClient client = new K3CloudApiClient("http://192.168.3.251/k3cloud/");
        //    var loginResult = client.ValidateLogin("6128407938e2f2", "Administrator", "Sshirt@1234", 2052);
        //    var resultType = JObject.Parse(loginResult)["LoginResultType"].Value<int>();
        //    //登录结果类型等于1，代表登录成功
        //    if (resultType == 1)
        //    {
        //        //自制
        //        String result = client.View("AP_OtherPayable", "{\"Number\":\"QTYFD00000002\",\"Id\":\"100002\"}");
        //    }
        //}
    }
    public class DouyinSaleDTO
    {
        public String styleNameCn { get; set; }
        public int saleCount { get; set; }
        public DouyinSaleDTO()
        {

        }

        public DouyinSaleDTO(string styleNameCn, int saleCount)
        {
            this.styleNameCn = styleNameCn;
            this.saleCount = saleCount;
        }
    }
}
